clear;%清理workspace中的所有变量
clc;
h=0.05;
x=0:h:pi;
syms x1;
y(x1)=sin(x1)/(x1^2+4*x1+3);
yy1=diff(y);
f1=yy1(x);
yy2=diff(yy1);
f2=yy2(x);
yy3=diff(yy2);
f3=yy3(x);
yy4=diff(yy3);
f4=yy4(x);
% disp("-----------------------------")
y=sin(x)./(x.^2+4*x+3);
[y1,dx1]=diff_ctr(y,h,1);
subplot(221),
plot(x,f1,dx1,y1,':');


[y2,dx2]=diff_ctr(y,h,2);
subplot(222),
plot(x,f2,dx2,y2,':');

[y3,dx3]=diff_ctr(y,h,3);
subplot(223),
plot(x,f3,dx3,y3,':');


[y4,dx4]=diff_ctr(y,h,4);
subplot(224),
plot(x,f4,dx4,y4,':')

disp('----------误差计算---------------------')
result=norm((y4-f4(4:60))./f4(4:60));
double(result)